%{
#include <stdio.h>
#include "main.h"
#include "y.tab.h"
#define YY_USER_INIT line=1;

%}

space	[ \t]

%%
;		{ return SEMICOLON; }
[a-zA-Z_,]+		{ 
			yylval = create_token(TOKEN);
			yylval->stringValue = strdup(yytext);
			yylval->data_type = SYMBOL;
			return WORD;
		}
0x[0-9a-fA-F]+	{ 
			yylval = create_token(TOKEN);
			yylval->stringValue = strdup(yytext);
			sscanf(yytext, "0x%x", &(yylval->i));
			yylval->data_type = INTEGER;
			return NUMBER;
		}
[0-9]+		{
			yylval = create_token(TOKEN);
			yylval->stringValue = strdup(yytext);
			yylval->i = atoi(yytext);
			yylval->data_type = INTEGER;
			return NUMBER;
		}
\(		{ return OPEN_BRACKET; }
\)		{ return CLOSE_BRACKET; }
\{		{ return OPEN_CURLY; }
\}		{ return CLOSE_CURLY; }
\n		{ line++; }
{space}		{ }
.		{ fprintf(stderr, "Parse error at line %d\n", line); exit(-1); }
%%
